Skip to content

fix: use structured logging for startup errors#235

Merged
jrobotham-square merged 1 commit intomainfrom
fix/structured-error-logging-startup
Mar 30, 2026
Merged

fix: use structured logging for startup errors#235
jrobotham-square merged 1 commit intomainfrom
fix/structured-error-logging-startup

Conversation

@jrobotham-square
Copy link
Copy Markdown
Contributor

Startup errors after the slog logger is initialized (config loading, metrics, server creation) were using kong's FatalIfErrorf, which writes plain unstructured text to stderr. Log aggregation systems cannot extract a log level from these messages, making them hard to filter and alert on.

This switches post-logger-init fatal errors to use slog.ErrorContext so they are emitted as structured logs with a proper ERROR level. Pre-logger errors (HCL parsing, global config) remain on kong since the logger isn't available yet.

Startup errors after the slog logger is initialized (config loading,
metrics, server creation) were using kong's FatalIfErrorf, which writes
plain unstructured text to stderr. Log aggregation systems cannot extract
a log level from these messages, making them difficult to find and alert
on.

Switch post-logger-init fatal errors to use slog.ErrorContext so they
are emitted as structured logs with a proper ERROR level. Pre-logger
errors (HCL parsing, global config) remain on kong since the logger
isn't available yet.

Amp-Thread-ID: https://ampcode.com/threads/T-019d3c97-9bcd-753d-bea7-bb117983acd6
Co-authored-by: Amp <amp@ampcode.com>
@jrobotham-square jrobotham-square marked this pull request as ready for review March 30, 2026 03:16
@jrobotham-square jrobotham-square requested a review from a team as a code owner March 30, 2026 03:16
@jrobotham-square jrobotham-square requested review from joshfriend and removed request for a team March 30, 2026 03:16
@jrobotham-square jrobotham-square merged commit 8310c39 into main Mar 30, 2026
7 checks passed
@jrobotham-square jrobotham-square deleted the fix/structured-error-logging-startup branch March 30, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants